<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>bsplin3val</title>
  </head>
  <body bgcolor="#FFFFFF">
    <center>Scilab Function</center>
    <div align="right">Last update : 24/03/2004</div>
    <p>
      <b>bsplin3val</b> - 3d spline arbitrary derivative evaluation function</p>
    <h3>
      <font color="blue">Calling Sequence</font>
    </h3>
    <dl>
      <dd>
        <tt>[dfp]=bsplin3val(xp,yp,zp,tl,der)</tt>
      </dd>
    </dl>
    <h3>
      <font color="blue">Parameters</font>
    </h3>
    <ul>
      <li>
        <tt>
          <b>xp, yp, zp</b>
        </tt>: real vectors or matrices of same size</li>
      <li>
        <tt>
          <b>tl</b>
        </tt>: tlist of type "splin3d", defining a 3d tensor spline (called <tt>
          <b>s</b>
        </tt> 
                in the following)</li>
      <li>
        <tt>
          <b>der</b>
        </tt>: vector with 3 components  <tt>
          <b>[ox,oy,oz]</b>
        </tt> defining which derivative of <tt>
          <b>s</b>
        </tt> 
                to compute.</li>
      <li>
        <tt>
          <b>dfp</b>
        </tt>: vector or matrix of same format than <tt>
          <b>xp</b>
        </tt>, <tt>
          <b>yp</b>
        </tt> and <tt>
          <b>zp</b>
        </tt>, 
                elementwise evaluation of the specified derivative of <tt>
          <b>s</b>
        </tt> on these points.</li>
    </ul>
    <h3>
      <font color="blue">Description</font>
    </h3>
    <p>
    While the function <a href="interp3d.htm">
        <tt>
          <b>interp3d</b>
        </tt>
      </a> may compute only the spline  <tt>
        <b>s</b>
      </tt> and
    its first derivatives, <tt>
        <b>bsplin3val</b>
      </tt> may compute any derivative of  <tt>
        <b>s</b>
      </tt>.
    The derivative to compute is specified by the argument  <tt>
        <b>der=[ox,oy,oz]</b>
      </tt> :
    </p>
    <pre>
               ox   oy   oz
              d    d    d
   dfp(i) =  ---  ---  ---   s (xp(i),yp(i),zp(i))
               ox   oy   oz
             dx   dy   dz
         </pre>
    <p>
    So <tt>
        <b>der=[0 0 0]</b>
      </tt> corresponds to <em>s</em>, <tt>
        <b>der=[1 0 0]</b>
      </tt>
    to <em>ds/dx</em>,  <tt>
        <b>der=[0 1 0]</b>
      </tt> to  <em>ds/dy</em>,  
    <tt>
        <b>der=[1 1 0]</b>
      </tt> to  <em>d2s/dxdy</em>, etc...
    </p>
    <p>
    For a point with coordinates <em>(xp(i),yp(i),zp(i))</em> outside the grid, the
    function returns 0.
    </p>
    <h3>
      <font color="blue">Examples</font>
    </h3>
    <pre>
deff("v=f(x,y,z)","v=cos(x).*sin(y).*cos(z)");
deff("v=fx(x,y,z)","v=-sin(x).*sin(y).*cos(z)");
deff("v=fxy(x,y,z)","v=-sin(x).*cos(y).*cos(z)");
deff("v=fxyz(x,y,z)","v=sin(x).*cos(y).*sin(z)");
deff("v=fxxyz(x,y,z)","v=cos(x).*cos(y).*sin(z)");
n = 20;  // n x n x n  interpolation points
x = linspace(0,2*%pi,n); y=x; z=x; // interpolation grid
[X,Y,Z] = ndgrid(x,y,z); V = f(X,Y,Z);
tl = splin3d(x,y,z,V,[5 5 5]);

// compute f and some derivates on a point
// and compare with the spline interpolant 
xp = grand(1,1,"unf",0,2*%pi); 
yp = grand(1,1,"unf",0,2*%pi); 
zp = grand(1,1,"unf",0,2*%pi); 

f_e = f(xp,yp,zp)
f_i = bsplin3val(xp,yp,zp,tl,[0 0 0])

fx_e = fx(xp,yp,zp)
fx_i = bsplin3val(xp,yp,zp,tl,[1 0 0])

fxy_e = fxy(xp,yp,zp)
fxy_i = bsplin3val(xp,yp,zp,tl,[1 1 0])

fxyz_e = fxyz(xp,yp,zp)
fxyz_i = bsplin3val(xp,yp,zp,tl,[1 1 1])

fxxyz_e = fxxyz(xp,yp,zp)
fxxyz_i = bsplin3val(xp,yp,zp,tl,[2 1 1])

 </pre>
    <h3>
      <font color="blue">See Also</font>
    </h3>
    <p>
      <a href="splin3d.htm">
        <tt>
          <b>splin3d</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="interp3d.htm">
        <tt>
          <b>interp3d</b>
        </tt>
      </a>,&nbsp;&nbsp;</p>
    <h3>
      <font color="blue">Authors</font>
    </h3>
    <dl>
      <dd>
        <b></b> R.F. Boisvert, C. De Boor (code from the CMLIB fortran lib)</dd>
      <dd>
        <b></b> B. Pincon (scilab interface)</dd>
    </dl>
  </body>
</html>
